﻿<?php 
include 'top1.php';
include '../connect.php';
?>

<div class="ny-right">

  <h3>账户管理</h3>

     <div id="twjs">
<br><br>



<?php
 if ($_GET['action']=='add'){
	
	$query = mysql_query("insert into room (rid,rname) values 
	
	('{$_POST['number']}','{$_POST['name']}')") or die(mysql_error());
		echo "<script type='text/javascript'>alert('添加成功');window.location.href='admin_room.php';</script>";
}
if ($_GET['action']=="del"){
	$query = mysql_query("delete from room where id= ".$_GET['id']);
	echo "<script type='text/javascript'>alert('删除成功');window.location.href='admin_room.php';</script>";
}


?>



<table border=1px cellpadding="0" cellspacing="0" width="670" style="margin:0 auto;">   
<?php 	
echo '<tr><td>学号</td><td>姓名</td><td>密码</td> </tr>';  
if ($_GET[page]==""){
$_GET[page]=1;}
if (is_numeric($_GET[page])){
$page_size=5;     							
$query="select count(*) as total from room  where rname like '{$_COOKIE['username']}' order by id desc";   
$result=mysql_query($query);      					//查询符合条件的记录总条数
$message_count=mysql_result($result,0,"total");		//要显示的总记录数
$page_count=ceil($message_count/$page_size);	  	//根据记录总数除以每页显示的记录数求出所分的页数
$offset=($_GET[page]-1)*$page_size;						//计算下一页从第几条数据开始循环  
$sql=mysql_query("select * from room where rname like '{$_COOKIE['username']}'  order by id desc limit $offset, $page_size");
$row=mysql_fetch_object($sql);
if(!$row){
echo "<font color='red'>暂无新闻信息!</font>";
}
do{
?>
   
 <tr><td><?php echo $row->id;?> </td><td><?php echo $row->rid;?> </td><td><?php echo $row->rname;?> </td></tr>
            
<?php
}
while($row=mysql_fetch_object($sql));
}
?>	
</table>
 





 <style  type="text/css">
 table td { padding-left:5px; }
  table td p { width:400px;word-break:break-all ;}
 
 </style>
 



</div>
</div>

<div class="clear"></div>
</div>


<?php 
include 'foot.php';

?>
